package za.org.jcicada.datastore.impl;

import za.org.jcicada.comms.IConnection;
import za.org.jcicada.comms.IMessageListener;
import za.org.jcicada.comms.impl.AcceptListenerBase;
import za.org.jcicada.datastore.IDataStoreServer;

/**
 * Katcomms accept listener that accepts connections and ties them to a given
 * IDataStoreServer.
 */
public class DataStoreAcceptListener extends AcceptListenerBase {

    /**
     * IDataStoreServer implementation to delegate requests to.
     */
    protected IDataStoreServer dataStoreServer;

    /**
     * Create an accept listener that listens for clients and passes messages
     * through to the given IAlarmSubject implementation.
     */
    public DataStoreAcceptListener(IDataStoreServer dataStoreServer) {
        this.dataStoreServer = dataStoreServer;
    }

    /**
     * Create message listeners for new connections. Implements abstract method
     * from AcceptListenerBase.
     * 
     * @param connection New connection from client.
     */
    @Override
    public IMessageListener createListener(IConnection connection) {
        return new DataStoreMessaging(connection, dataStoreServer);
    }

}
